'''
异常处理
'''

person = dict(name="zhangsan",age=18)
# person.aaaa #AttributeError: 'dict' object has no attribute 'aaaa'
print(person["name"])

print("出错后的代码")

# bbb = person.get("bbb")
# print(bbb)


# try:
#     # 提示用户输入一个数字
#     num = int(input("请输入数字：")) # ValueError
# except:
#     print("出错了，请输入正确的数字")



try:
    num = int(input("请输入整数："))
    result = 8 / num

    print(result)
    # print(person["dddd"])
except ValueError:
    print("请输入正确的整数")
except ZeroDivisionError:
    print("除 0 错误")
except Exception as e1:
    print("未知异常")
    print(dir(e1))
    print("__cause__",e1.__cause__)
else:
    print("程序完美执行，没有报错")
finally:
    print("无论异常与否都执行的 Finally")
print('hello')



